<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:th="http://www.thymeleaf.org">
<head>
   <!-- http://129.204.170.237:8000/-->
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7 charset=utf-8" />
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title></title>
    <meta name="description" content="" />
    <!--<script type="text/javascript" src="index.php?act=jslang"></script>-->
    <link href="http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/css/shop.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/jquery/jquery-1.8.3.min.js" charset="utf-8"></script>
    <script charset="utf-8" type="text/javascript" src="http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/js/jqzoom.js" ></script>
    <link rel="stylesheet" type="text/css" href="http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/css/jqzoom.css"/>
    <script src="http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/layui/layui.all.js"></script>

</head>

<body>
<script th:inline="javascript">
    var url1 = "http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/show/shoppingCart";//加入购物车的链接
    var url2  ="http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/show/purchase";//立即采购的链接
    /*<![CDATA[*/

    var mintrade = [[${product.mintrade}]];//为id为quantity的元素服务，最小批发数量

    /*]]>*/
</script>

<div id="site-nav" class="w-full">

</div>
<div id="header" class="w-full">
    <div class="shop-t w clearfix pb10 mb5 mt5">
        <div class="logo mt10">

        </div>
        <div class="top-search">
            <div class="top-search-box clearfix">
                <ul class="top-search-tab clearfix">
                    <li id="index" class="current"><span>商品</span></li>
                    <!--<li id="store"><span>批发商</span></li>-->
                    <!--<li id="groupbuy"><span>拼货</span></li>-->
                </ul>
                <div class="form-fields">
                    <form method="GET" action="index.php?app=search">
                        <input type="hidden" name="app" value="search" />
                        <input type="hidden" name="act" value="index" />
                        <input type="text"   name="keyword" value="" class="keyword kw_bj index_bj " />
                        <input type="submit" value="搜索" class="submit" hidefocus="true" />
                    </form>
                </div>
            </div>
            <div class="top-search-keywords">
                <span>热门搜索：</span>
                <a style="color:#EE3000;" href="">土豆</a>
                <a  href="">地瓜</a>
                <a  href="">鲜肉</a>
                <a style="color:#EE3000;" href="">玉米</a>
                <a  href="">高粱</a>
                <a  href="">大米</a>
                <a style="color:#EE3000;" href="">胡萝卜</a>
            </div>
        </div>
        <div class="header_cart">
            <div class="title clearfix">
                <b></b><a href="index.php?app=cart">去购物车结算</a><em></em>
            </div>
            <div class="shadow"></div>
            <div class="cart-list">
                <div class="nogoods clearfix">
                    <b></b>购物车中还没有商品，赶紧选购吧！
                </div>
            </div>
        </div>
    </div>
    <div class="w-full mall-nav">
        <ul class="w clearfix">
            <li class="allcategory float-left">
                <a class="allsort" href="" target="_blank">全部分类</a>

            </li>

            </li>
            <li class="each float-left inline-block"><a  href="">首页</a></li>
        </ul>
    </div>
</div>
<div id="path">
    当前位置:
    <a href="http://www.wancai188.com/index.php">首页</a> <span>&#8250;</span>

    </div>

<div id="mystore" class="w auto clearfix">
    <div class="goods_info_top">
        <div class="goods_info">


            <div class="ware_info clearfix">
                <div class="ware_pic">
                    <div class="big_pic">
                        <a href=""><span class="jqzoom"><img th:src="@{'/imgs/'+${product.img1}}" width="400" height="300" style="object-fit: contain;" jqimg="@{'/imgs/'+${product.img1}}" /></span></a>
                    </div>

                    <div class="bottom_btn">
                        <!--<a class="collect" href="javascript:collect_goods(107);" title="收藏该商品"></a>-->
                        <!--<div class="left_btn"></div>
                        <div class="right_btn"></div>-->
                        <div class="ware_box">
                            <ul>
                                <li class="ware_pic_hover" th:bigimg="@{'/imgs/'+${product.img1}}">
                                    <img  class = "smallImg" th:src="@{'http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/imgs/'+${product.img1}}"/></li>
                                <li style="line-height: 60px;" th:bigimg="@{'/imgs/'+${product.img2}}"><img  class = "smallImg" th:src="@{'/imgs/'+${product.img2}}"/></li>
                                <li style="line-height: 60px;" th:bigimg="@{'/imgs/'+${product.img3}}"><img  class = "smallImg" th:src="@{'/imgs/'+${product.img3}}"></li>
                            </ul>
                        </div>
                    </div>

                </div>

                <div class="ware_text">
                    <h2 class="ware_title"  th:text="${product.headline}"></h2>
                    <div class="rate">
                        <div class="cpxxy_jg"><span>起批量&nbsp;&nbsp;&nbsp;：<span th:text="${product.mintrade}"></span>&nbsp;&nbsp;斤</span></br>
                            <span class="letter1">价格：</span><span class="fontColor3" ectype="goods_price"  th:text="${product.price}"></span><span class="fontColor3">/斤</span></div>
                        <div style="padding-left:15px;" class="cpxxy_xlqk">销售情况：售出 <span th:text="${product.sold}"></span> 斤（<span class="c3b8"><strong>213</strong></span> 条评论）</div>
                    </div>
                    <div class="handle">
                        <ul>
                            <li class="handle_title">购买数量：</li>
                            <li >
                                <a class="jianshao" href="javascript:void(0);" title="减少" onclick="if (document.getElementById('quantity').value>mintrade){document.getElementById('quantity').value--;}">
                                    <img src = "http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/images/jian.png"  width="30" height="30"/>
                                </a>
                                <input type="text" class="text width1" name="" id="quantity" th:value="${product.mintrade}" style=" background:#fff;float:left;" />
                                <a class="zengjia" href="javascript:void(0);" title="增加" onclick="document.getElementById('quantity').value++;">
                                    <img src = "http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/images/jia.png" width="30" height="30"/>
                                </a>
                                件（库存<span class="stock" ectype="goods_stock" th:text="${product.stock}"></span>斤）
                            </li>
                        </ul>
                        <div style="clear:both; height:0; display:block; overflow:hidden;"></div>
                    </div>


                    <ul class="ware_btn">

                        <li class="btn_c1" id="purchase" title="立刻购买"><a onclick="purchase()">立即采购</a></li>
                        <li class="btn_c2" id="addCar" title="加入购物车"><a onclick="addCar()"a>加入进货单</a></li>
                    </ul>
                </div>

            </div></div>
        <div class="goods_right">
            <div id="store-owner" class="w190 box">
                <div class="goods_right_r">
                    <h2>-----热销商品----</h2>
                    <ul>
                    </ul>
                </div>
            </div>
        </div>
    </div>
    <div class="col-sub w190">
        <div class="module_common"  style="display:none">
            <h2 class="common_title">
                <span class="ico1"><span class="ico2">店内搜索</span></span>
            </h2>
            <div class="wrap">
                <div class="wrap_child">
                    <div class="web_search" style="">
                        <form id="" name="" method="get" action="index.php">
                            <input type="hidden" name="app" value="store" />
                            <input type="hidden" name="act" value="search" />
                            <input type="hidden" name="id" value="9" />
                            <label>关键字</label>
                            <input type="text" name="keyword" style="width:110px;border:1px #ccc solid; height:20px; line-height:20px;" value="" />
                            <input class="btn" type="submit" value="搜索" />
                        </form>
                    </div>
                </div>
            </div>
        </div>

        <div class="module_common store-category" >
            <h2 class="common_title">
                <div class="ornament1"></div>
                <div class="ornament2"></div>
                <span class="ico1">商品分类</span>
            </h2>
            <div class="wrap">
                <div class="wrap_child">
                    <ul class="submenu">
                        <li>
                            <a class="block_ico" href="index.php?app=store&amp;id=9&amp;act=search&amp;cate_id=462">生腊味系</a>
                            <ul>
                                <li><a href="index.php?app=store&amp;id=9&amp;act=search&amp;cate_id=463">五花腊肉</a></li>
                                <li><a href="index.php?app=store&amp;id=9&amp;act=search&amp;cate_id=464">后腿腊肉</a></li>
                                <li><a href="index.php?app=store&amp;id=9&amp;act=search&amp;cate_id=465">腊猪耳朵</a></li>
                                <li><a href="index.php?app=store&amp;id=9&amp;act=search&amp;cate_id=466">腊鱼</a></li>
                                <li><a href="index.php?app=store&amp;id=9&amp;act=search&amp;cate_id=467">腊猪脸</a></li>
                                <li><a href="index.php?app=store&amp;id=9&amp;act=search&amp;cate_id=468">腊鱼尾</a></li>
                                <li><a href="index.php?app=store&amp;id=9&amp;act=search&amp;cate_id=1615">黑猪腊肉</a></li>
                            </ul>
                        </li>

                    </ul>
                </div>
            </div>
        </div>



        <div class="module_common">
            <h2 class="common_title">
                <div class="ornament1"></div>
                <div class="ornament2"></div>
                <span class="ico1"><span class="ico2">热门商品</span></span>
            </h2>
            <div class="wrap">
                <div class="major">
                    <ul class="list" style="width:188px; text-align:center">
                        <li>
                            <div class="pic"><a th:href="@{'enter?id='+${product.id}}" target="_blank"><img th:src="@{'http://106.12.215.182:8080/hello-0.0.1-SNAPSHOT/imgs/'+${product.img1}}" width="165" height="165" /></a></div>
                            <h3><a href="index.php?app=goods&amp;id=105" target="_blank" th:text="${product.headline}"></a></h3>
                            <p th:text="${product.price}"><!--<em></em>--></p>
                        </li>

                    </ul>
                </div>
            </div>
        </div>


    </div>
    <div class="col-main w750">


        <a name="module"></a>
        <ul class="user_menu">
            <div class="ornament1"></div>
            <div class="ornament2"></div>
            <li><a class="active" th:href="@{'detail?pid='+${product.id}}" target="right"><span>商品详情</span></a></li>
            <li><a class="normal" th:href="@{'comment?pid='+${product.id}}" target="right"><span>商品评论</span></a></li>
            <li><a class="normal" th:href="@{'saleNote?pid='+${product.id}}" target="right"><span>销售记录</span></a></li>
            <li><a class="normal" th:href="@{'consult?pid='+${product.id}}" target="right"><span>产品咨询</span></a></li>
        </ul>
        <iframe th:src="@{'saleNote?pid='+${product.id}}" frameborder="no" border="0" marginheight="0" scrolling="no" id="right" name="right"
                style="padding:20px;border:1px solid #ddd;overflow: hidden; border-top:0px; width:958px;height:-webkit-fill-available;">
            <div class="goods_parameters">
                <h4>产品参数：</h4>



                <table style="">
                    <tr>
                        <td><em>产品名称：</em><span th:text="${product.veget}"></span></td>
                        <td><em>产品出产地：</em>
                            <span th:text="${product.province}"></span> >
                            <span th:text="${product.city}"></span> >
                            <span th:text="${product.district}"></span>
                        </td>
                    </tr>
                    <tr>
                        <td><em>联系人：</em><span th:text="userName"></span></td>
                        <td><em>卖家联系方式：</em><span th:text="userTel"></span></td>
                    </tr>
                    <tr>
                        <td colspan="2">产品描述：<br/>
                            &nbsp;    &nbsp;    &nbsp;
                            <span th:if = "${product.detail}!=''" th:text = "${product.detail}"></span>
                            <span th:if = "${product.detail}==''">卖家很懒，什么也没写</span>
                        </td>
                    </tr>
                </table>
            </div>
            <div class="option_box">


            </div>
        </iframe>
    </div>

</div>


</div>
<script th:inline="javascript">
    /*<![CDATA[*/


        var price = [[${product.price}]];
        var pid = [[${#httpServletRequest.getParameter('id')}]];
        var userid = [[${product.userid}]];
        var num = document.getElementById('quantity').value;
        var sum = num * price;
        var json={};

        json.price = price;
        json.pid = pid;
        json.userid = userid;
        json.num = num;
        json.sum = num * price;
        var order = JSON.stringify(json);
    function addCar() {
        $.ajax({
            url: url1,
            contentType: "application/json",
            type:"post",
            data:order,
            success:function(data)
            {
                layer.alert(data, {
                    title: '加入购物车成功'
                })
            },
            error: function () {
                console.log("未知错误");
            }
        });
    }
    function purchase() {
        if(confirm("确定购买吗?本次购买将消费"+sum+"元")){
        $.ajax({
            url:url2,
            type:"post",
            contentType:"application/json",
            data:order,
            success:function(data)
            {
                layer.alert(data, {
                    title: '采购成功'
                })
            },
            error: function () {
                console.log("未知错误");
                 }
            });

        }
    }
    /*]]>*/
</script>
            <script type="text/javascript">
            /* 购买前提示*/
                function buy()
                {
                    if (goodsspec.getSpec() == null)
                    {
                        alert(lang.select_specs);
                        return;
                    }
                    var spec_id = goodsspec.getSpec().id;

                    var quantity = $("#quantity").val();
                    if (quantity == '')
                    {
                        alert(lang.input_quantity);
                        return;
                    }
                    if (parseInt(quantity) < 1)
                    {
                        alert(lang.invalid_quantity);
                        return;
                    }
                    add_to_cart(spec_id, quantity);
                }

                /* 加入购物车 */
                function add_to_cart(spec_id, quantity)
                {
                    var url = SITE_URL + '/index.php?app=cart&act=add';
                    $.getJSON(url, {'spec_id':spec_id, 'quantity':quantity}, function(data){
                        if (data.done)
                        {
                            $('.bold_num').text(data.retval.cart.kinds);
                            $('.bold_mly').html(price_format(data.retval.cart.amount));
                            $('.ware_cen').slideDown('slow');
                            setTimeout(slideUp_fn, 5000);
                            alert("加入成功");
                            //alert(lang.select_specs);
                            return;
                        }
                        else
                        {
                            alert(data.msg);
                        }
                    });
                }

                /*buy_now*/
                function buy_now()
                {
                    //验证数据
                    if (goodsspec.getSpec() == null)
                    {
                        alert(lang.select_specs);
                        return;
                    }
                    var spec_id = goodsspec.getSpec().id;

                    var quantity = $("#quantity").val();
                    if (quantity == '')
                    {
                        alert(lang.input_quantity);
                        return;
                    }
                    if (parseInt(quantity) < 1)
                    {
                        alert(lang.invalid_quantity);
                        return;
                    }
                    buy_now_add_cart(spec_id, quantity);
                }

                /* add buy_now_add_cart */
                function buy_now_add_cart(spec_id, quantity)
                {
                    var url = "";
                    $.getJSON(url, {'spec_id':spec_id, 'quantity':quantity}, function(data){
                        if (data.done)
                        {
                            location.href= "";
                        }else{
                            alert(data.msg);
                        }
                    });
                }

                var specs = new Array();
                specs.push(new spec(119, '', '', 68.00, 575));
                var specQty = 0;
                var defSpec = 119;
                var goodsspec = new goodsspec(specs, specQty, defSpec);
                //]]>
            </script>


</body>
</html>